/**
 *   @author Giulio Rossetti <Giulio.Rossetti@gmail.com>
 *   @version 0.2alpha
 *
 *   This file is part of "JXMLSwing".
 *
 *   "JXMLSwing" is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   "JXMLSwing" is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package jxmlswing;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;


/**
 * @author Giulio Rossetti <Giulio.Rossetti@gmail.com>
 * @version 0.2alpha
 */
public class XMLtoJava {

	private TransformerFactory tFactory;

	public XMLtoJava(){
		tFactory = TransformerFactory.newInstance();
	}

	public void generateCode(String XMLfile) throws TransformerException, TransformerConfigurationException,
		FileNotFoundException, IOException{

		Transformer transformer = this.tFactory.newTransformer(new
		StreamSource("src/Template/ClassSchema.xsl"));

		transformer.transform(new StreamSource(XMLfile), new StreamResult(new FileOutputStream(XMLfile.replace("xml", "java"))));

	}
}

